package com.mes.service.manu;

import com.yy.base.common.dao.Dao;
import com.yy.base.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class CuttingJobsService extends BaseService {
	@Autowired
	private Dao dao;


	//根据矢量图编码带出对应明细信息
	public List<Map<String,Object>> getPhotoLists(String code) {

		return dao.query("SELECT  " +
				"  zy.CODE AS ZYCODE,  " +
				"  ys.NAME AS YSNAME,  " +
				"  xz.emes_file_id ,  " +
				"  bw.name as BWNAME,  " +
				"  fl.emeso_job_paiban_id  " +
				" FROM  " +
				"  Emeso_Job_Paiban pb,  " +
				"  Emeso_Job_Order_Material fl,  " +
				"  emes_shape xz,  " +
				"  Emeso_Job_Order zy,  " +
				"  Emes_Color ys,  " +
				"  emes_component bw  " +
				" WHERE  " +
				"  pb.emeso_job_paiban_id = fl.emeso_job_paiban_id   " +
				"  AND fl.emes_shape_id = xz.emes_shape_id   " +
				"  AND fl.emeso_job_order_id = zy.emeso_job_order_id   " +
				"  AND ys.emes_color_id = fl.emes_color_id  " +
				"  AND fl.emes_component_id = bw.emes_component_id  " +
				"  AND fl.STATUS IN ( 'PAIBAN', 'OK' ) " +
				"  AND pb.code = '"+code+"'");

		/*return dao.query("SELECT  " +
				"  zy.code as ZYCODE , ys.name as YSNAME ,lz.path as PATH , com.name as BWNAME " +
				"  FROM  " +
				"  Emeso_Job_Paiban pb,  " +
				"  Emeso_Job_Order_Material fl ,  " +
				"  emes_shape xz ,   " +
				"  emes_file lz, " +
				"  Emeso_Job_Order zy,  " +
				"  Emes_Color  ys,  " +
				"  Emes_PBom boms,  " +
				"  Emes_PBom_Item_Shape item,  " +
				"  Emes_PBom_Item bw,  " +
				"  Emes_Component com  " +
				"WHERE  " +
				"  pb.emeso_job_paiban_id = fl.emeso_job_paiban_id   " +
				"  and fl.emes_shape_id = xz.emes_shape_id  " +
				"  and fl.emeso_job_order_id = zy.emeso_job_order_id  " +
				"  and ys.emes_color_id = fl.emes_color_id  " +
				"  and boms.m_product_id = zy.m_product_id  " +
				"  and fl.emes_shape_id = item.emes_shape_id  " +
				"  and boms.emes_pbom_id = bw.emes_pbom_id  " +
				"  and bw.emes_component_id = com.emes_component_id  " +
				//"  and gx.emes_process_id = fl.emes_process_id   " +
				"  and xz.emes_file_id = lz.emes_file_id " +
				// "  and gx.route_no = '30' " +
				"  and fl.status in ('PAIBAN','OK')  " +
				"  AND pb.code = '"+code+"'");*/
	}


	//根据矢量图编码带出对应明细信息
	public List<Map<String,Object>> getJobOrderList(String code) {

		return dao.query("SELECT      " +
				"            pb.CODE AS photo,      " +
				"            zy.CODE AS plancode,      " +
				"            wl.VALUE  AS wlcode,     " +
				"             bw.name as BWNAME,  " +
				"             item.data as TEXT,  " +
				"            to_char ( pb.created, 'yyyy-mm-dd' ) AS times,      " +
				"            ( CASE fl.STATUS WHEN 'CREATE' THEN '创建' WHEN 'PAIBAN' THEN '已排版' WHEN 'OK' THEN '已完成' ELSE '' END ) AS zystatus       " +
				"        FROM      " +
				"            Emeso_Job_Order_Material fl,      " +
				"            emeso_job_order zy,      " +
				"            Emeso_Job_Paiban pb,      " +
				"            m_product wl,       " +
				"    Emes_Component bw ,  " +
				"    emes_shape_item item  " +
				"   WHERE      " +
				"    zy.emeso_job_order_id = fl.emeso_job_order_id       " +
				"    AND fl.emeso_job_paiban_id = pb.emeso_job_paiban_id       " +
				"    AND zy.m_product_id = wl.m_product_id       " +
				"    AND fl.emes_component_id = bw.emes_component_id       " +
				"    and fl.emes_shape_id = item.emes_shape_id  " +
				"    and zy.emes_size_id = item.emes_size_id " +
				"    AND zy.CODE = '"+code+"'");

		/*return dao.query("SELECT    " +
				"    pb.CODE AS photo,    " +
				"    zy.CODE AS plancode,    " +
				"    wl.    " +
				"VALUE    " +
				"    AS wlcode,    " +
				"    com.NAME AS bwname,    " +
				"    item.DATA AS text,    " +
				"    to_char ( pb.created, 'yyyy-mm-dd' ) AS times,    " +
				"    ( CASE fl.STATUS WHEN 'CREATE' THEN '创建' WHEN 'PAIBAN' THEN '已排版' WHEN 'OK' THEN '已完成' ELSE '' END ) AS zystatus     " +
				"FROM    " +
				"    Emeso_Job_Order_Material fl,    " +
				"    emeso_job_order zy,    " +
				"    Emeso_Job_Paiban pb,    " +
				"    m_product wl,    " +
				"    Emes_PBom boms,    " +
				"    Emes_PBom_Item_Shape item,    " +
				"    Emes_PBom_Item bw,    " +
				"    Emes_Component com     " +
				"WHERE    " +
				"    zy.emeso_job_order_id = fl.emeso_job_order_id     " +
				"    AND fl.emeso_job_paiban_id = pb.emeso_job_paiban_id     " +
				"    AND zy.m_product_id = wl.m_product_id     " +
				"    AND boms.m_product_id = zy.m_product_id     " +
				"    AND fl.emes_shape_id = item.emes_shape_id "     +
				"    AND boms.emes_pbom_id = bw.emes_pbom_id     " +
				"    AND bw.emes_component_id = com.emes_component_id     " +
				"    AND zy.CODE = '"+code+"'");*/
	}

}